package p270jp.pxv.android.view;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import androidx.databinding.DataBindingUtil;
import p014ae.View$OnClickListenerC0046a;
import p014ae.View$OnClickListenerC0054c;
import p090d0.C2518n;
import p144f1.C3017s;
import p184gi.AnalyticsParameter;
import p270jp.pxv.android.R;
import p270jp.pxv.android.legacy.model.PixivNovel;
import p270jp.pxv.android.legacy.model.PixivWork;
import p274k2.ContextCompat;
import p314lg.ViewNovelItemBinding;
import p325m0.MutabilityOwnership;
import p374nm.BaseMuteLayout;
import p470ri.HashtagService;
import p677zi.PixivImageLoader;

/* renamed from: jp.pxv.android.view.NovelItemView */
/* loaded from: classes2.dex */
public class NovelItemView extends BaseMuteLayout {

    /* renamed from: b */
    public PixivNovel f19587b;

    /* renamed from: c */
    public boolean f19588c;

    /* renamed from: d */
    public OnMarkButtonClickListener f19589d;

    /* renamed from: e */
    public ViewNovelItemBinding f19590e;

    /* renamed from: f */
    public final HashtagService f19591f = (HashtagService) C2518n.m7641d(HashtagService.class);

    /* renamed from: g */
    public final PixivImageLoader f19592g = (PixivImageLoader) C2518n.m7641d(PixivImageLoader.class);

    /* renamed from: jp.pxv.android.view.NovelItemView$OnMarkButtonClickListener */
    /* loaded from: classes2.dex */
    public interface OnMarkButtonClickListener {
        void onMarkButtonClick();
    }

    /* renamed from: jp.pxv.android.view.NovelItemView$a */
    /* loaded from: classes2.dex */
    public enum EnumC4381a {
        NONE,
        /* JADX INFO: Fake field, exist only in values array */
        LIKE,
        MARK
    }

    public NovelItemView(Context context) {
        super(context);
    }

    @Override // p374nm.BaseMuteLayout
    /* renamed from: a */
    public View mo3337a() {
        ViewNovelItemBinding kaVar = (ViewNovelItemBinding) DataBindingUtil.m11370c(LayoutInflater.from(getContext()), R.layout.view_novel_item, this, false);
        this.f19590e = kaVar;
        kaVar.f21855x.setOnClickListener(new View$OnClickListenerC0046a(this, 22));
        this.f19590e.f21853v.setOnClickListener(new View$OnClickListenerC0054c(this, 28));
        return this.f19590e.f2666e;
    }

    public PixivNovel getNovel() {
        return this.f19587b;
    }

    public void setAnalyticsParameter(AnalyticsParameter cVar) {
        this.f19590e.f21851t.setAnalyticsParameter(cVar);
    }

    public void setButtonType(EnumC4381a aVar) {
        int ordinal = aVar.ordinal();
        if (ordinal == 1) {
            this.f19590e.f21851t.setVisibility(0);
            this.f19590e.f21853v.setVisibility(8);
        } else if (ordinal != 2) {
            this.f19590e.f21851t.setVisibility(8);
            this.f19590e.f21853v.setVisibility(8);
        } else {
            this.f19590e.f21851t.setVisibility(8);
            this.f19590e.f21853v.setVisibility(0);
        }
    }

    public void setIgnoreMuted(boolean z) {
        this.f19588c = z;
    }

    public void setIsMarked(boolean z) {
        if (z) {
            Context context = getContext();
            Object obj = ContextCompat.f19963a;
            Drawable b = ContextCompat.C4472c.m4259b(context, R.drawable.ic_novel_list_marker_marked);
            Context context2 = getContext();
            MutabilityOwnership.m3745m(context2, "context");
            TypedValue typedValue = new TypedValue();
            if (context2.getTheme().resolveAttribute(R.attr.colorCharcoalMarker, typedValue, true)) {
                b.setTint(typedValue.data);
                this.f19590e.f21853v.setImageDrawable(b);
                return;
            }
            throw new IllegalStateException("Charcoal Theme, もしくは Charcoal Bridge Theme を利用してください");
        }
        this.f19590e.f21853v.setImageResource(R.drawable.ic_novel_list_marker);
    }

    public void setMarkButtonEnabled(boolean z) {
        this.f19590e.f21853v.setEnabled(z);
    }

    public void setNovel(PixivNovel pixivNovel) {
        if (C3017s.m6470f(pixivNovel, this.f19588c)) {
            setMuteCoverVisibility(0);
            return;
        }
        this.f19587b = pixivNovel;
        setMuteCoverVisibility(8);
        this.f19592g.m59g(getContext(), pixivNovel.imageUrls.getMedium(), this.f19590e.f21850s);
        this.f19590e.f21852u.setText(String.valueOf(pixivNovel.totalBookmarks));
        this.f19590e.f21857z.setText(pixivNovel.title);
        this.f19590e.f21848q.setText(String.format("by %s", pixivNovel.user.name));
        String c = this.f19591f.m2578c(pixivNovel);
        this.f19590e.f21856y.setText(String.format("%s%s%s", getResources().getString(R.string.novel_words_format, Integer.valueOf(pixivNovel.textLength)), "  ", c));
        if (pixivNovel.series.f19077id > 0) {
            this.f19590e.f21855x.setVisibility(0);
            this.f19590e.f21855x.setText(pixivNovel.series.title);
            return;
        }
        this.f19590e.f21855x.setVisibility(8);
    }

    public void setOnMarkButtonClickListener(OnMarkButtonClickListener onMarkButtonClickListener) {
        this.f19589d = onMarkButtonClickListener;
    }

    public void setWorkForLikeButton(PixivWork pixivWork) {
        this.f19590e.f21851t.setWork(pixivWork);
    }

    public NovelItemView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }
}
